package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;
import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;
import com.jrzh.framework.base.search.BaseSearch;

public class TableHistorySearch extends BaseSearch{
	private static final long serialVersionUID = 1L;
	
	
    /**
     * Equal 表格ID
     */
    private String equalTableId;
	
    /**
     * Equal 表格名称
     */
    private String equalTableName;
    
    /**
     * Like 表格名称
     */
    private String likeTableName;
    
     /**
     * In 表格名称 英文逗号分隔
     */
    private String inTableNames;
    
    /**
     * Equal 操作类型
     */
    private String equalOprationType;
    
    /**
     * Like 操作类型
     */
    private String likeOprationType;
    
     /**
     * In 操作类型 英文逗号分隔
     */
    private String inOprationTypes;
    
    /**
     * Equal sql语句
     */
    private String equalSql;
    
    /**
     * Like sql语句
     */
    private String likeSql;
    
     /**
     * In sql语句 英文逗号分隔
     */
    private String inSqls;

    public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public void setEqualTableName(String equalTableName) {
        this.equalTableName = equalTableName;
    }
    
    public String getEqualTableName() {
        return this.equalTableName;
    }
    
    public void setLikeTableName(String likeTableName) {
        this.likeTableName = likeTableName;
    }
    
    public String getLikeTableName() {
        return this.likeTableName;
    }
    
    public void setInTableNames(String inTableNames) {
        this.inTableNames = inTableNames;
    }
    
    public String getInTableNames() {
        return this.inTableNames;
    }
    public void setEqualOprationType(String equalOprationType) {
        this.equalOprationType = equalOprationType;
    }
    
    public String getEqualOprationType() {
        return this.equalOprationType;
    }
    
    public void setLikeOprationType(String likeOprationType) {
        this.likeOprationType = likeOprationType;
    }
    
    public String getLikeOprationType() {
        return this.likeOprationType;
    }
    
    public void setInOprationTypes(String inOprationTypes) {
        this.inOprationTypes = inOprationTypes;
    }
    
    public String getInOprationTypes() {
        return this.inOprationTypes;
    }
    public void setEqualSql(String equalSql) {
        this.equalSql = equalSql;
    }
    
    public String getEqualSql() {
        return this.equalSql;
    }
    
    public void setLikeSql(String likeSql) {
        this.likeSql = likeSql;
    }
    
    public String getLikeSql() {
        return this.likeSql;
    }
    
    public void setInSqls(String inSqls) {
        this.inSqls = inSqls;
    }
    
    public String getInSqls() {
        return this.inSqls;
    }

	@Override
	public void setCriterias(Criteria<?> criterias) {
	    if(StringUtils.isNotBlank(equalTableId)){
			criterias.add(Restrictions.eq("tableId", equalTableId));
		}
	    if(StringUtils.isNotBlank(equalTableName)){
			criterias.add(Restrictions.eq("tableName", equalTableName));
		}
	    if(StringUtils.isNotBlank(likeTableName)){
			criterias.add(Restrictions.allLike("tableName", likeTableName));
		}
		 if(StringUtils.isNotBlank(inTableNames)){
			criterias.add(Restrictions.in("tableName", StringUtils.split(inTableNames, ",")));
		}
	    if(StringUtils.isNotBlank(equalOprationType)){
			criterias.add(Restrictions.eq("oprationType", equalOprationType));
		}
	    if(StringUtils.isNotBlank(likeOprationType)){
			criterias.add(Restrictions.allLike("oprationType", likeOprationType));
		}
		 if(StringUtils.isNotBlank(inOprationTypes)){
			criterias.add(Restrictions.in("oprationType", StringUtils.split(inOprationTypes, ",")));
		}
	    if(StringUtils.isNotBlank(equalSql)){
			criterias.add(Restrictions.eq("sql", equalSql));
		}
	    if(StringUtils.isNotBlank(likeSql)){
			criterias.add(Restrictions.allLike("sql", likeSql));
		}
		 if(StringUtils.isNotBlank(inSqls)){
			criterias.add(Restrictions.in("sql", StringUtils.split(inSqls, ",")));
		}
	}
}